package cn.wolfcode.trip.api.controller;

import cn.wolfcode.trip.base.domain.CityPlay;
import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.query.CityplayQueryObject;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IApplicantService;
import cn.wolfcode.trip.base.service.ICityPlayService;
import cn.wolfcode.trip.base.util.JsonResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("cityPlay")
public class CityPlayController {

    @Autowired
    private ICityPlayService cityPlayService;

    @Autowired
    private IApplicantService applicantService;


    @GetMapping("list")
    public PageInfo query(@ModelAttribute("qo")CityplayQueryObject qo){
        //查询查出所有的的一起去旅游的信息
        PageInfo<CityPlay> query = cityPlayService.query(qo);
        return query;
    }

    @GetMapping("list/{cityPlayId}")
    public List<User> selectAllBycityPlayId(@ModelAttribute("qo")CityplayQueryObject qo, @PathVariable Long cityPlayId){

        //查出一条约旅游信息所参加的人数的姓名头像电话
        List<User> users=applicantService.selectAllBycityPlayId(cityPlayId);
        return users;
    }

    @GetMapping("user/{cityId}")
    public PageInfo selectUserBycityId(@ModelAttribute("qo")CityplayQueryObject qo){
        //根据对应的结伴id查出所对应的作者和他的头像
        PageInfo<CityPlay> query = cityPlayService.query(qo);
        return query;
    }
}
